import { defineConfig } from 'vite'
const { resolve } = require('path')
import vue from '@vitejs/plugin-vue'
import viteImagemin from 'vite-plugin-imagemin';
import viteCompression from 'vite-plugin-compression';

module.exports = {
  resolve: { alias: { '@': resolve(__dirname, 'src') } },
  plugins: [
    vue(),
    {
      ...viteImagemin({
        gifsicle: {
          optimizationLevel: 7,
          interlaced: false,
        },
        optipng: {
          optimizationLevel: 7,
        },
        webp: {
          quality: 75,
        },
        mozjpeg: {
          quality: 65,
        },
        pngquant: {
          quality: [0.65, 0.9],
          speed: 4,
        },
        svgo: {
          plugins: [
            {
              removeViewBox: false,
            },
            {
              removeEmptyAttrs: false,
            },
          ],
        },
        verbose:true,
      }),
      name: 'build-viteImagemin',
      apply: 'build'
    },
    {
      ...viteCompression(),
      apply: 'build'
    },
  ],
  server: {
    port: 33332,
    open: true,
    proxy: {
      '/wy': {
        target: 'http://testapi.tdconnect.cn',
        changeOrigin: true,
      },
    },
  },
  build: {
    rollupOptions: {
      // https://rollupjs.org/guide/en/#big-list-of-options或https://www.rollupjs.com/
      plugins: [],//里面放rollup插件
    }
  },
}
